package com.skb.task.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

/**
 * @Author 沈楷博
 * @Company 永遠快樂
 * @Description
 * @Time 2024/9/10 下午4:07
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Task {
    private Long taskId;
    private String taskTitle;
    private String taskDesc;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", locale = "zh", timezone = "Asia/Shanghai")
    private Date startTime;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", locale = "zh", timezone = "Asia/Shanghai")
    private Date endTime;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", locale = "zh", timezone = "Asia/Shanghai")
    private Date createTime;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", locale = "zh", timezone = "Asia/Shanghai")

    private Date modifyTime;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date startTimeBegin;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date startTimeEnd;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endTimeBegin;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endTimeEnd;
    private Integer taskDuration;
    private Integer taskProgress;
    private Integer taskParent;
    private Long taskParentId;
    private Long userId;
    private String projectId;
    private Integer taskStatus;
    private User user;
    private Project project;
    private List<Task> children;// 子任务列表
    private Boolean hasChildren; // 是否有子任务
    public void setTaskParent(Integer taskParent) {
        this.taskParent = taskParent;
        if (this.taskParent.equals(new Integer(1))) {
            this.hasChildren = true; // 如果是父级任务，说明有子任务，将hasChildren设置为true
        } else {
            this.hasChildren = false;
        }
    }
}